NAME ?= led
TOOL ?= arm-linux-gnueabihf-


CC := $(TOOL)gcc
LD := $(TOOL)ld
LD_ADDR := 0x87800000
OBJCOPY := $(TOOL)objcopy
OBJDUMP := $(TOOL)objdump


$(NAME).bin: start.o main.o
	$(LD) -Ttext $(LD_ADDR) $^ -o $(NAME).elf
	$(OBJCOPY) -O binary $(NAME).elf $@
	$(OBJDUMP) -D $(NAME).elf > $(NAME).dis

%.o:%.c
	$(CC) -c $< -o $@
%.o:%.s
	$(CC) -c $< -o $@

clear:
	rm *.o $(NAME).elf $(NAME).dis $(NAME).bin